/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DataEvaluation;

import DataSelection.TaxonomyParser;
import java.util.ArrayList;

/**
 *
 * @author Manuel
 */
public class DataArranger {
    private boolean related;
    private boolean theSame;

    public DataArranger(){
        this.related = false;
    }

    public ArrayList<String[][]> getPairs(ArrayList<String[]> allvalues, TaxonomyParser taxonomyParser, int no_concept1){

        
        ArrayList<String[][]> dataPairs = new ArrayList<String[][]>();
        int projectno = allvalues.size();

        //create an array for each column (=attribute)
        ArrayList<String[]> columns = this.createColumns(allvalues,taxonomyParser);

        

        //associate each property of concept 1 to each of concept 2
        for(int i = 0;i<no_concept1;i++){
            for(int j = no_concept1;j<columns.size();j++){
                String[][] newPair = new String[2][allvalues.size()];
                newPair[0] = columns.get(i);
                newPair[1] = columns.get(j);
                if(columns.get(i)[0].equals(columns.get(j)[0])){
                    related = true;
                }
                else{
                    dataPairs.add(newPair);
                }

            }
        }

        return dataPairs;

    }



    public ArrayList<String[]> createColumns(ArrayList<String[]> allvalues,TaxonomyParser taxonomyParser) {
        ArrayList<String[]> columns = new ArrayList<String[]>();


        for(int i = 0;i<allvalues.get(0).length-1;i++){
            columns.add(new String[allvalues.size()]);
        }
        for(int i = 0;i<allvalues.size();i++){
            String[] currentArray = allvalues.get(i);
            for(int j = 0;j<currentArray.length-1;j++){
                columns.get(j)[i] = currentArray[j+1];
            }
        }
        //mark the columns that are on class level with *c
        for(String[] current : columns){
            if(current[1].contains("(")){
                current[0] = current[0]+"*c";
            }
        }
        return columns;
    }

    public boolean isRelated() {
        return related;
    }


}
